package com.naihe.anderson.sms.util;

public class DateTimeUtil {

	public static String getCountdown(long differTime) {
		StringBuffer buffer = new StringBuffer();
		int ss = 1000;
		int mi = ss * 60;
		int hh = mi * 60;
		int dd = hh * 24;

		long day = differTime / dd;
		long hour = (differTime - day * dd) / hh;
		long minute = (differTime - day * dd - hour * hh) / mi;
		long second = (differTime - day * dd - hour * hh - minute * mi) / ss;

		if(day < 10 && day > 0){
			buffer.append("0" + day).append("天");
		} else if(day >= 10){
			buffer.append(day).append("天");
		}
		
		if(hour < 10 && hour > 0){
			buffer.append("0" + hour).append("时");
		} else if(hour >= 10){
			buffer.append(hour).append("时");
		}
		
		if(minute < 10 && minute > 0){
			buffer.append("0" + minute).append("分");
		} else if(minute >= 10){
			buffer.append(minute).append("分");
		}
		
		if(second < 10 && second > 0){
			buffer.append("0" + second).append("秒");
		} else if(second >= 10){
			buffer.append(second).append("秒");
		}
		
		return buffer.toString();
	}
}
